package com.jsoup.service.impl;

import com.jsoup.bean.Comment;
import com.jsoup.mapper.CommentMapper;
import com.jsoup.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Resource
    private CommentMapper commentMapper;

    @Override
    public int deleteByPrimaryKey(Integer commentId) {
        return commentMapper.deleteByPrimaryKey(commentId);
    }

    @Override
    public int insert(Comment comment) {
        return commentMapper.insert(comment);
    }

    @Override
    public int insertSelective(Comment comment) {
        return commentMapper.insertSelective(comment);
    }

    @Override
    public Comment selectByPrimaryKey(Integer commentId) {
        return commentMapper.selectByPrimaryKey(commentId);
    }

    @Override
    public int updateByPrimaryKeySelective(Comment comment) {
        return commentMapper.updateByPrimaryKeySelective(comment);
    }

    @Override
    public int updateByPrimaryKey(Comment comment) {
        return commentMapper.updateByPrimaryKey(comment);
    }

    @Override
    public List<Comment> selectComment(Comment comment) {
        return commentMapper.selectComment(comment);
    }

    @Override
    public Comment getComment(Comment comment) {
        List<Comment> list = this.selectComment(comment);
        if (list == null || list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }
}
